The jtkversion.tcl library is distributed as part of the jstools package. It consists of procedures to make it easier to write scripts that will work under both Tk 3 and Tk 4.
This document describes jtkversion.tcl version 3.6/3.0.
Usage
Accessing the Library
In order to use the jtkversion.tcl library, it (and any other libraries it depends on) must be in your Tcl auto_path, described in tclvars(n). Information about how to arrange that, and other conventions common to the jstools libraries, is in the Usage section of The jstools Libraries.
Credits and Copyright
Author
Jay Sekora
js@bu.edu
http://shore.net/~js/
Copyright
The library is copyright ⌐ 1992-1994 by Jay Sekora, but may be freely copied and modified for non¡commercial purposes. (Please contact me if you want to use it for a commercial purpose, this may be OK under some circumstances.)
Overview
Procedures
j:tk4 - perform an action if running under Tk version 4 or greater
j:tk3 - perform an action if running under Tk version 3 or earlier
j:current_focus - return current focus
See Also
jtkutils.tcl
j:tk4
Usage
j:tk4 [command]
Description
This procedure executes command (in the calling procedure's stack frame) if and only if running under Tk version 4 or later. It returns 1 if the command was executed (i.e., if the version of Tk it's running under is 4 or greater) and 0 otherwise. If command is omitted, no action is performed, but the return value still indicates what version of Tk is being used.
j:tk3
Usage
j:tk3 [command]
Description
This procedure executes command (in the calling procedure's stack frame) if and only if running under Tk version 3 or earlier. It returns 1 if the command was executed (i.e., if the version of Tk it's running under is 3 or less) and 0 otherwise. If command is omitted, no action is performed, but the return value still indicates what version of Tk is being used.
j:current_focus
Usage
j:current_focus
Description
This procedure simply returns the window that currently has the focus. It hides differences in the focus(n) command between Tk versions 3 and 4.
Unfortunately, it also hides Tk 4's ability to support windows on multiple displays in the same application; under Tk 4, it always returns the window with the focus on the same display as the Tk main window, `.'.
Evolution
Feel free to report bugs (and feature requests) to me, <js@bu.edu>, and I will try to deal with them. Also, feel free to fix bugs or add features on your own and let me know how you did it.
Bugs and Misfeatures
* All these procedures are really misfeatures. :-) They'll probably go away in the future as Tk 4 becomes more prevalent and Tk 3 dies out.
* As mentioned, j:current_focus doesn't handle multiple displays.
Future Directions
* These procedures are a stop¡gap solution to get the jstools applications and libraries, which are written for Tk 3.6, to run under Tk 4.0. In the future jstools will be upgraded to support Tk 4.0 directly, so these procedures may go away.